import { request } from "@/utils/http";
import {
  Departments,
  ProvinceResponse,
  ReqGetDoctorsParams,
  ReqGetDoctorsResponse,
  ReqGetHospitalListParams,
  ReqGetHospitalListResponse,
  ReqGetHospitalScheduleParams,
  ReqGetHospitalScheduleResponse,
  ReqGetHospitalShowResponse,
} from "./model/hospitalTypes";

//获取所有的省份
export function reqGetProvinces(type: string) {
  return request.get<any, ProvinceResponse>(
    `/admin/cmn/dict/findByDictCode/${type}`
  );
}

//获取市区和县的信息
export function reqGetCityOrDistrict(id: number) {
  return request.get<any, ProvinceResponse>(
    `/admin/cmn/dict/findByParentId/${id}`
  );
}

//获取医院列表数据
export function reqGetHospitalList({
  page,
  limit,
  ...args
}: ReqGetHospitalListParams) {
  return request.get<any, ReqGetHospitalListResponse>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      params: args,
    }
  );
}

//封装函数 获取医院的详细内容
export function reqGetHospitalShow(id: string){
  return request.get<any, ReqGetHospitalShowResponse>(`/admin/hosp/hospital/show/${id}`); 
}

//封装函数 获取医院的科室
export function reqGetHospitalDepartments(hoscode: string){
  return request.get<any, Departments>(`/admin/hosp/department/${hoscode}`);
}

//封装函数 获取某个医院某个科室未来的排班规则
export function reqGetHospitalSchedule({page, limit, hoscode, depcode}: ReqGetHospitalScheduleParams){
  return request.get<any, ReqGetHospitalScheduleResponse>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`)
}

//封装函数 获取某个医院某个科室未来某一天排班医生
export function reqGetDoctors({hoscode, depcode, workDate}: ReqGetDoctorsParams){
  return request.get<any, ReqGetDoctorsResponse>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`)
}

//更新医院的上下线状态
export function reqUpdateHospitalStatus(id: string, status: number){
  return request.get<any, null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`);
}